package work20241227;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zdl
 * @date 2024/12/27
 */
@FunctionalInterface
interface A{
    void a();
}
interface  B{
    void b(int num);
}
interface C{
    void c(int a,int b);
}
interface D{
    int d(int a ,int b);
}
public class Demo1 {
    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(2, 6, 10, TimeUnit.MINUTES, new ArrayBlockingQueue<>(4));
        poolExecutor.execute(() -> System.out.println(Thread.currentThread().getName()));
        test1(() -> System.out.println("test1"));
        test2((n) -> System.out.println(n),99);
        test3((a,b) -> System.out.println(a+b),10,20);
        test4((a,b)-> a*b,2,5);
        test4((a,b)-> {
            for (int i = 0; i < 5; i++) {
                System.out.println(i);
            }
            return a + b;
        },4,7);
    }
    public static void test1(A a){
        a.a();
    }
    public static void test2(B b,int n){
        b.b(n);
    }
    public static void test3(C c, int a,int d){
        c.c(a,d);
    }
    public static void test4(D d,int a,int b){
        System.out.println(d.d(a, b));
    }
}
